package com.itheima.reflect;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class ReflactDemo6 {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        ClassLoader loader = ClassLoader.getSystemClassLoader();
        InputStream is = loader.getResourceAsStream("prop.properties");

        Properties prop = new Properties();
        prop.load(is);

        String cn = prop.getProperty("className");
        String mn = prop.getProperty("methodName");

        Class c = Class.forName(cn);
        Constructor con = c.getConstructor();
        Object o = con.newInstance();
        Method m = c.getMethod(mn,String.class);
        m.invoke(o,"zhangsan");
    }
}
